/**
 * app列表中的星星控件
 */
package net.youpo.Market.UI;

import net.youpo.Market.R;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class StarView extends LinearLayout {
	private ImageView star1;
	private ImageView star2;
	private ImageView star3;
	private ImageView star4;
	private ImageView star5;

	public StarView(Context context) {
		super(context);
	}

	public StarView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		inflater.inflate(R.layout.starview, this);
		star1 = (ImageView) findViewById(R.id.imageView1);
		star2 = (ImageView) findViewById(R.id.imageView2);
		star3 = (ImageView) findViewById(R.id.imageView3);
		star4 = (ImageView) findViewById(R.id.imageView4);
		star5 = (ImageView) findViewById(R.id.imageView5);
	}

	/**
	 * ���÷����ܷ�ʮ��
	 */
	public void setPoint(int point) {
		switch (point) {
		case 0: {
			star1.setImageResource(R.drawable.star_empty);
			star2.setImageResource(R.drawable.star_empty);
			star3.setImageResource(R.drawable.star_empty);
			star4.setImageResource(R.drawable.star_empty);
			star5.setImageResource(R.drawable.star_empty);
			break;
		}
		case 1: {
			star1.setImageResource(R.drawable.star_half);
			star2.setImageResource(R.drawable.star_empty);
			star3.setImageResource(R.drawable.star_empty);
			star4.setImageResource(R.drawable.star_empty);
			star5.setImageResource(R.drawable.star_empty);
			break;
		}
		case 2: {
			star1.setImageResource(R.drawable.star);
			star2.setImageResource(R.drawable.star_empty);
			star3.setImageResource(R.drawable.star_empty);
			star4.setImageResource(R.drawable.star_empty);
			star5.setImageResource(R.drawable.star_empty);
			break;
		}
		case 3: {
			star1.setImageResource(R.drawable.star);
			star2.setImageResource(R.drawable.star_half);
			star3.setImageResource(R.drawable.star_empty);
			star4.setImageResource(R.drawable.star_empty);
			star5.setImageResource(R.drawable.star_empty);
			break;
		}
		case 4: {
			star1.setImageResource(R.drawable.star);
			star2.setImageResource(R.drawable.star);
			star3.setImageResource(R.drawable.star_empty);
			star4.setImageResource(R.drawable.star_empty);
			star5.setImageResource(R.drawable.star_empty);
			break;
		}
		case 5: {
			star1.setImageResource(R.drawable.star);
			star2.setImageResource(R.drawable.star);
			star3.setImageResource(R.drawable.star_half);
			star4.setImageResource(R.drawable.star_empty);
			star5.setImageResource(R.drawable.star_empty);
			break;
		}
		case 6: {
			star1.setImageResource(R.drawable.star);
			star2.setImageResource(R.drawable.star);
			star3.setImageResource(R.drawable.star);
			star4.setImageResource(R.drawable.star_empty);
			star5.setImageResource(R.drawable.star_empty);
			break;
		}
		case 7: {
			star1.setImageResource(R.drawable.star);
			star2.setImageResource(R.drawable.star);
			star3.setImageResource(R.drawable.star);
			star4.setImageResource(R.drawable.star_half);
			star5.setImageResource(R.drawable.star_empty);
			break;
		}
		case 8: {
			star1.setImageResource(R.drawable.star);
			star2.setImageResource(R.drawable.star);
			star3.setImageResource(R.drawable.star);
			star4.setImageResource(R.drawable.star);
			star5.setImageResource(R.drawable.star_empty);
			break;
		}
		case 9: {
			star1.setImageResource(R.drawable.star);
			star2.setImageResource(R.drawable.star);
			star3.setImageResource(R.drawable.star);
			star4.setImageResource(R.drawable.star);
			star5.setImageResource(R.drawable.star_half);
			break;
		}
		case 10: {
			star1.setImageResource(R.drawable.star);
			star2.setImageResource(R.drawable.star);
			star3.setImageResource(R.drawable.star);
			star4.setImageResource(R.drawable.star);
			star5.setImageResource(R.drawable.star);
			break;
		}
		default:
			star1.setImageResource(R.drawable.star);
			star2.setImageResource(R.drawable.star);
			star3.setImageResource(R.drawable.star);
			star4.setImageResource(R.drawable.star);
			star5.setImageResource(R.drawable.star);
		}
	}
}
